class Anchor {

	private _x: number = 0;

	private _y: number = 0;

	private functionList: Array<Function> = null;

	public constructor(x: number = 0, y: number = 0) {
		this._x = x;
		this._y = y;
		this.functionList = new Array();
	}


	public get x(): number {
		return this._x;
	}

	public update(x: number, y: number): void {
		var func: Function = null;
		this._x = x;
		this._y = y;
		for (var i = 0; i < this.functionList.length; i++) {
			func = this.functionList[i];
			func(this);
		}
	}

	public addListener(func: Function): void {
		this.removeListener(func);
		this.functionList.push(func);
	}

	public removeListener(func: Function): void {
		let i = this.functionList.length;
		while (i--) {
			if (this.functionList[i] == func) {
				this.functionList.splice(i, 1);
			}
		}
	}

	public get y(): number {
		return this._y;
	}
}
